import { _decorator, Component, Node, Vec3 } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('Bg')
export class Bg extends Component {
    @property(Node)
    bg01:Node = null;
    @property(Node)
    bg02:Node = null;
    @property
    speed:number = 100;
    start() {
    }

    update(deltaTime: number) {
        this.bg01.setPosition(this.bg01.getPosition().add3f(0, -this.speed * deltaTime, 0));
        this.bg02.setPosition(this.bg02.getPosition().add3f(0, -this.speed * deltaTime, 0));
        if(this.bg01.getPosition().y < -852){
            this.bg01.setPosition(this.bg02.getPosition().add3f(0, 852, 0));
        }
        if(this.bg02.getPosition().y < -852){
            this.bg02.setPosition(this.bg01.getPosition().add3f(0, 852, 0));
        }
    }
}


